<!--回款明细-->
<template>
  <div>
    <f-table ref='table'
             rowKey='orderDetailsReturnId'
             :showSetting='false'
             setting-key='returnAmountTab1'
             :tableColumns='columns'
             :scroll='{x:true}'
             :showMultipleBtn='false'
             :showPagination='false'
             :showTotal='true'
             :multiple='false'
             handler='returnDetailsPageListHandler'
             :operator='operator'
             :autoLoad='false'
             :pageSize='80'
             :params='queryParam'
             :api='api.hyOrderDetailsReturn.list'>
       <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
           <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
       </span>
      <span slot='action' slot-scope='text, record'>
         <template v-if='record.rowIndex!="合计"'>
            <a @click='$refs.overModal.open(record)' v-if='superAdmin'>超期差额</a>
             <a-divider type='vertical' v-if='superAdmin'/>
            <a href='javascript:;' @click='$refs.orderDetailsDrawer.showDrawer(record)'>详情</a>
          </template>
      </span>
    </f-table>

    <hy-order-details-drawer ref='orderDetailsDrawer'></hy-order-details-drawer>
    <over-modal ref='overModal'></over-modal>
  </div>
</template>
<script>
import api from "./../../../js/api"
import HyOrderDetailsDrawer from "@/views/module/haiying/order/details/hyorder_details_drawer"
import OverModal from "@/views/module/haiying/order/return/components/over_modal"

export default {
  name: "ReturnDetails",
  components: { OverModal, HyOrderDetailsDrawer },
  data() {
    let me = this
    //操作按钮
    let operator = []

    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      //列表初始化查询参数
      queryParam: {
        auth: 1,
        isFlp: 1
      },
      returnCustomBond: 0,
      selectIds: "",
      params1: {
        deptId: ""
      },
      dataSource: [],
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "left",
          fixed: "left",
          dataIndex: "rowIndex",
          customRender: function(text, record, index) {
            return (record.rowIndex !== "合计") ? (parseInt(index) + 1) : record.rowIndex
          }
        },
        {
          title: "订单编号",
          align: "center",
          width: "130px",
          fixed: "left",
          dataIndex: "orderNo"
        },
        {
          title: "发货单号",
          align: "center",
          width: "130px",
          fixed: "left",
          dataIndex: "outOrderNo"
        },
        {
          title: "发(退)货日期",
          align: "left",
          width: "100px",
          dataIndex: "sendDate"
        },
      /*  {
          title: "回款日期",
          align: "center",
          width: "80px",
          dataIndex: "returnDate"
        },*/
        {
          title: "业务员",
          align: "left",
          width: "100px",
          dataIndex: "saleManName"
        },
        {
          title: "业务员编码",
          align: "left",
          width: "100px",
          dataIndex: "businessCode"
        },
        {
          title: "部门名称",
          align: "left",
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "单位名称",
          align: "left",
          width: "130px",
          ellipsis: true,
          dataIndex: "customName"
        },
        {
          title: "商品名称",
          align: "left",
          ellipsis: true,
          width: "140px",
          dataIndex: "drugsName"
        },
        {
          title: "批号",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "drugLotNo"
        },
        {
          title: "规格",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "drugsSpec"
        },
        {
          title: "类型",
          align: "left",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "销售单价",
          align: "center",
          width: "80px",
          dataIndex: "salePrice"
        },
        {
          title: "渠道商结算价",
          align: "center",
          width: "80px",
          dataIndex: "settlePrice"
        },
       /* {
          title: "超期天数",
          align: "center",
          width: "80px",
          dataIndex: "settleOverDay"
        },*/
        {
          title: "超期结算价",
          align: "center",
          width: "80px",
          dataIndex: "settleOverPrice"
        },
        {
          title: "超期差额",
          align: "center",
          width: "80px",
          dataIndex: "overDateAmount"
        },
        {
          title: "数量",
          align: "center",
          width: "80px",
          needTotal: true,
          fixed: "right",
          dataIndex: "saleNum"
        },
        {
          title: "发货金额",
          align: "left",
          width: "100px",
          needTotal: true,
          fixed: "right",
          dataIndex: "saleAmount"
        },{
          title: "操作",
          align: "center",
          width: "120px",
          dataIndex: "action",
          fixed: "right",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  computed: {},
  methods: {
    setData(data) {
      if (data && data.paymentId) {
        this.queryParam.returnId = data.paymentId
        this.$refs["table"].refresh(false)
      }
    },
    //部门切换
    deptChange(value) {
      this.queryParam.deptId = value
      //this.openMultiple()
      this.$refs.saleMan.initData(this.queryParam)
      this.$refs.table.refresh(true, this.queryParam)
      this.$forceUpdate()
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },

    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    }
  },
  created() {
  }
}
</script>